import { Authority } from '@/domain/entity/Authority';
import { ResponsePage } from '@/domain/entity/ResponsePage';
import { AuthorityListQuery } from '@/domain/query/AuthorityListQuery';
import { RoleListQuery } from '@/domain/query/RoleListQuery';
import axios from '../config/AxiosConfig';
import { Result } from '../domain/entity/Result';

const moduleUrl = "/system/system-authority";

const getListUrl = moduleUrl + "/getList";
// const getTreeListUrl = moduleUrl + "/getTreeList";
const getListPageUrl = moduleUrl + "/getListPage";
const getDetailUrl = moduleUrl + "/getDetail";
const createAuthorityUrl = moduleUrl + "/create";
const updateAuthorityUrl = moduleUrl + "/update";
const updateShowStatusUrl = moduleUrl + "/updateShowStatus";
const updateDisabledUrl = moduleUrl + "/updateDisabled";
const deleteAuthorityUrl = moduleUrl + "/delete";

export const getList = function () {
    return axios.get<Result<Array<Authority>>>(getListUrl);
}

export const getListPage = function (authorityListQuery: AuthorityListQuery) {
    return axios.get<Result<ResponsePage<Authority>>>(getListPageUrl, {
        params: authorityListQuery,
    });
}

export const getDetail = function (authorityId: string) {
    return axios.get<Result<Authority>>(getDetailUrl + "/" + authorityId);
}



export function update(currentEntity: Authority) {
    return axios.put<Result<Authority>>(updateAuthorityUrl, currentEntity);
}

export function create(currentEntity: Authority) {
    return axios.post<Result<Authority>>(createAuthorityUrl, currentEntity);
}

export function remove(authorityId: string) {
    return axios.delete<Result<string>>(deleteAuthorityUrl + "/" + authorityId);
}

export function updateDisabled(authorityId: string) {
    return axios.put<Result<string>>(updateDisabledUrl + "/" + authorityId);
}

// 弃用,暂时没有
export function updateShowStatus(authorityId: string) {
    return axios.put<Result<string>>(updateShowStatusUrl + "/" + authorityId);
}
